package it.uniroma2.art.coda.structures;

import it.uniroma2.art.coda.pearl.model.PlaceholderStruct;
import it.uniroma2.art.owlart.model.ARTURIResource;

import java.util.HashMap;
import java.util.Map;

/**
 * This class contains the map linking a placeholder to its already existing value inside the ontology. This
 * class should be instantiated only by the Identity Resolver component
 * 
 * @author Andrea Turbati
 * 
 */
public class BindLabelToExistingARTURIResource extends InterComponentObject {

	Map<PlaceholderStruct, Map<String, ARTURIResource>> placeholderToARTURIResMap;

	public BindLabelToExistingARTURIResource() {
		placeholderToARTURIResMap = new HashMap<PlaceholderStruct, Map<String, ARTURIResource>>();
	}

	/**
	 * Add a new placeholder, its value (a string) and the associated ontology resource to the map
	 * 
	 * @param placeholder
	 *            the placeholder
	 * @param valueOfFeat
	 *            the value for this placeholder (a string)
	 * @param res
	 *            the already existing resource inside the ontology
	 */
	public void addBindLabelARTURIResource(PlaceholderStruct placeholder, String valueOfFeat,
			ARTURIResource res) {
		if (!placeholderToARTURIResMap.containsKey(placeholder)) {
			placeholderToARTURIResMap.put(placeholder, new HashMap<String, ARTURIResource>());
		}
		Map<String, ARTURIResource> artUriResMAp = placeholderToARTURIResMap.get(placeholder);
		artUriResMAp.put(valueOfFeat, res);
	}

	/**
	 * Get the complete map contained in this instance
	 * 
	 * @return the complete map placeholder-value
	 */
	public Map<PlaceholderStruct, Map<String, ARTURIResource>> getPlaceholderToARTURIResMap() {
		return placeholderToARTURIResMap;
	}

	/**
	 * Get the list of value associated to a placeholder
	 * 
	 * @param placeholder
	 *            the placeholder to which the values are associated to
	 * @return the values associated to a placeholder
	 */
	public Map<String, ARTURIResource> getArtResourceMapFromPlaceholder(PlaceholderStruct placeholder) {
		return placeholderToARTURIResMap.get(placeholder);
	}
}
